home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / cenviw1.zip / WINLIST.CMM < prev    next >
Text File  |  1993-06-26  |  1KB  |  38 lines

  1. // WinList.cmm  Display a list of all windows and all their child windows
  2.  
  3. DisplayWindowChildren(0,NULL);
  4.  
  5. DisplayWindowChildren(ChildDepth,ParentHandle)
  6. {
  7.    WList = WindowList(ParentHandle);
  8.    if ( NULL == WList ) return;   // if no windows in this list, then nothing to display
  9.    count = 1 + GetArraySpan(WList);
  10.    for ( i = 0; i < count; i++ ) {
  11.       hwnd = WList[i];
  12.       // to avoid printing all windows more than once, only print if the direct
  13.       // parent is the ParentHandle of this depth
  14.       if ( ParentHandle == GetParentHandle(hwnd) ) {
  15.          printf("\n%*d",7 * ChildDepth,hwnd);
  16.          PrintWindowTextIfAny(hwnd)
  17.          DisplayWindowChildren(ChildDepth+1,hwnd);
  18.       }
  19.    }
  20. }
  21.  
  22. PrintWindowTextIfAny(handle) // print name of window if it has one
  23. {
  24.    #define MAX_TEXT_LEN 50
  25.    BLObSize(buf,MAX_TEXT_LEN+1);
  26.    if ( 0 != DynamicLink("USER","GETWINDOWTEXT",SWORD16,PASCAL,
  27.                          handle,buf,MAX_TEXT_LEN) )
  28.       printf("   %s",buf);
  29. }
  30.  
  31. GetParentHandle(WindowHandle)
  32. {
  33.    return( DynamicLink("USER","GETPARENT",SWORD16,PASCAL,WindowHandle) );
  34. }
  35.  
  36. getch();
  37.  
  38.